package net.dopan.pigframe.demo.controller;

import com.google.gson.Gson;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import net.dopan.pigframe.api.fegin.OSSServiceApi;
import net.dopan.pigframe.config.utils.IdentityVrification;
import net.dopan.pigframe.config.utils.JavaBeanUtil;
import net.dopan.pigframe.config.utils.SubListUtils;
import net.dopan.pigframe.core.base.controller.response.ResponseBean;
import net.dopan.pigframe.demo.mapper.UserActivityMapper;
import net.dopan.pigframe.demo.model.entity.CommentLike;
import net.dopan.pigframe.demo.model.entity.UserActivityParticipant;
import net.dopan.pigframe.demo.model.entity.vo.*;
import net.dopan.pigframe.demo.service.UserActivityParticipantService;
import net.dopan.pigframe.demo.service.UserActivityService;
import net.dopan.pigframe.demo.service.ribbon.OssServerRibbon;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author wufeihong 活动中心
 */
@RestController
@RequestMapping("/userActivityCenter")
public class UserActivityCenterController {

    @Qualifier("OSSServiceFallback")
    @Autowired
    private OSSServiceApi ossServiceApi;

    @Autowired
    private UserActivityMapper userActivityMapper;

    @Autowired
    private UserActivityParticipantService userActivityParticipantService;
    @Autowired
    private UserActivityService userActivityService;
    @Autowired
    private HttpServletRequest request;
    @Autowired
    private OssServerRibbon ossServerRibbon;
    @Autowired
    private HttpServletResponse response;

    /**
     * 获取活动
     *
     * @param
     * @return
     */
    @PostMapping("/getHotUserActivity")
    @ApiOperation("获取热门活动")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "timeSelection", value = "weekend(周末)  a_week(一周) a_month(一个月)", required = false, dataType = "String"),
            @ApiImplicitParam(name = "lat2", value = "用户当前位置的纬度", required = false, dataType = "String"),
            @ApiImplicitParam(name = "lng2", value = "用户当前位置的经度", required = false, dataType = "String"),
            @ApiImplicitParam(name = "type", value = "类型 0按时间排序 1 按距离排序", required = false, dataType = "String"),
            @ApiImplicitParam(name = "province", value = "省", required = false, dataType = "String"),
            @ApiImplicitParam(name = "city", value = "市", required = false, dataType = "String"),
            @ApiImplicitParam(name = "area", value = "区", required = false, dataType = "String"),
            @ApiImplicitParam(name = "userId", value = "当前用户的Id", required = true, dataType = "String"),
            @ApiImplicitParam(name = "pageNum", value = "页码", required = true, dataType = "String"),
            @ApiImplicitParam(name = "pageSize", value = "页数", required = true, dataType = "String")

    })
    public ResponseBean getHotUserActivity(FindUserActivityVo findUserActivityVo, @RequestParam("pageNum") String pageNum, @RequestParam("pageSize") String pageSize) {
        /** 允许该域发起跨域请求 */
        response.setHeader("Access-Control-Allow-Origin", "*");
        /**  允许的外域请求方式 */
        response.setHeader("Access-Control-Allow-Methods", "POST, GET");
        Map<String, String> map = JavaBeanUtil.convertBeanToMap(findUserActivityVo);
        map.put("hot", "1");
        List<UserActivityVo> list = userActivityService.findUserActivityVo(map);
        return new ResponseBean(ResponseBean.SUCCESS, "", SubListUtils.subList(Integer.parseInt(pageNum), Integer.parseInt(pageSize), list));

    }

    /**
     * 参加活动
     *
     * @param userActivityParticipant
     * @return
     */
    @GetMapping("/entryActivity")
    @ApiOperation("参加活动")
    public ResponseBean entryActivity(UserActivityParticipant userActivityParticipant) {

        /** 允许该域发起跨域请求 */
        response.setHeader("Access-Control-Allow-Origin", "*");
        /**  允许的外域请求方式 */
        response.setHeader("Access-Control-Allow-Methods", "POST, GET");
        Integer activityId = userActivityParticipant.getActivityId();
        Integer userId = userActivityParticipant.getUserId();
        if (userActivityService.getIdentityVerification(String.valueOf(userId)) != 1) {
            return new ResponseBean(ResponseBean.FAIL, "请先验证身份!", "");
        }
        List<Map<String, String>> map = userActivityService.getUserActivityParticipant(activityId, userId);
        if (map != null && !map.isEmpty()) {
            return new ResponseBean(ResponseBean.SUCCESS, "活动已参加!", "");
        }
        int entryActivityNum = userActivityService.findEntryActivityNum(activityId);
        int peopleNumber = (int) userActivityService.getUserActivity(activityId).getPeopleNumber();

        if (entryActivityNum + 1 > peopleNumber) {
            return new ResponseBean(ResponseBean.FAIL, "人数已满!", "");
        }
        userActivityParticipantService.addUserActivityParticipant(userActivityParticipant);
        return new ResponseBean(ResponseBean.SUCCESS, "报名成功!", "");

    }

    @PostMapping("/identityVerification")
    @ApiOperation("身份验证")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "当前用户Id", required = true, dataType = "String"),
            @ApiImplicitParam(name = "cardNo", value = "身份证号码", required = true, dataType = "String"),
            @ApiImplicitParam(name = "realName", value = "真实姓名", required = true, dataType = "String")
    })
    public ResponseBean identityVerification(@RequestParam("userId") String userId, @RequestParam("cardNo") String cardNo, @RequestParam("realName") String realName) {

        /** 允许该域发起跨域请求 */
        response.setHeader("Access-Control-Allow-Origin", "*");
        /**  允许的外域请求方式 */
        response.setHeader("Access-Control-Allow-Methods", "POST, GET");
        if (userActivityService.getIdentityVerification(userId) == 1) {
            return new ResponseBean(ResponseBean.SUCCESS, "用户已验证!", "");
        }
        if (IdentityVrification.getCode(cardNo, realName).equals("0")) {
            userActivityService.updateIdentityVrification(userId);
            return new ResponseBean(ResponseBean.SUCCESS, "验证成功!", "");
        }
        return new ResponseBean(ResponseBean.FAIL, "验证失败!", "");
    }

    /**
     * 获取照片墙
     *
     * @param activityId
     * @return
     */
    @GetMapping("getPotoWall")
    @ApiOperation("获取照片墙")
    public ResponseBean getPhotoWall(@RequestParam("activityId") String activityId, @RequestParam("userId") String userId) {

        /** 允许该域发起跨域请求 */
        response.setHeader("Access-Control-Allow-Origin", "*");
        /**  允许的外域请求方式 */
        response.setHeader("Access-Control-Allow-Methods", "POST, GET");
        return new ResponseBean(ResponseBean.SUCCESS, "", userActivityService.getPhotoWall(activityId, userId));
    }

    /**
     * 添加图片到图片墙
     *
     * @param activityId
     * @param photo
     * @return
     */
    @PostMapping("addPhotoIntoWall")
    @ApiOperation("添加图片到图片墙")
    public ResponseBean addPhotoIntoWall(@RequestParam("activityId") String activityId, @RequestParam("photo") MultipartFile photo, @RequestParam("userId") String userId) {

        /** 允许该域发起跨域请求 */
        response.setHeader("Access-Control-Allow-Origin", "*");
        /**  允许的外域请求方式 */
        response.setHeader("Access-Control-Allow-Methods", "POST, GET");
        /** 上传图片到服务器 */
//        System.err.println(ossServerRibbon.getConfig());
        StringBuilder photoUrl = new StringBuilder();
        photoUrl.append("https://activityplatform.oss-cn-hangzhou.aliyuncs.com/");
        try {
            String str = ossServerRibbon.upload(photo, request);
            System.err.println(str);
            Gson gson = new Gson();
            Map<String, Object> map = new HashMap<String, Object>();
            map = gson.fromJson(str, map.getClass());
            photoUrl.append((String) map.get("data"));
        } catch (IOException e) {
            e.printStackTrace();
        }
        userActivityService.addPhotoIntoWall(Integer.parseInt(activityId), photoUrl.toString(), userId);
        return new ResponseBean(ResponseBean.SUCCESS, "发布成功!", "");
    }

    @GetMapping("addActivityComment")
    @ApiOperation("添加活动评论")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "activityId", value = "活动Id", required = true, dataType = "String"),
            @ApiImplicitParam(name = "commentMsg", value = "评论内容", required = true, dataType = "String"),
            @ApiImplicitParam(name = "userId", value = "评论用户Id", required = true, dataType = "String")
    })
    @Transactional
    public ResponseBean addActivityComment(ActivityCommentVo activityCommentVo) {

        /** 允许该域发起跨域请求 */
        response.setHeader("Access-Control-Allow-Origin", "*");
        /**  允许的外域请求方式 */
        response.setHeader("Access-Control-Allow-Methods", "POST, GET");
        Integer num = userActivityService.getCommentNum(String.valueOf(activityCommentVo.getActivityId())) == null ? 0 : userActivityService.getCommentNum(String.valueOf(activityCommentVo.getActivityId())) + 1;
        activityCommentVo.setCommentNum(num);
        return new ResponseBean(ResponseBean.SUCCESS, "添加评论成功!", userActivityService.addActivityComment(activityCommentVo));
    }

    @GetMapping("addUserNoteComment")
    @ApiOperation("添加笔记评论")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "noteId", value = "活动Id", required = true, dataType = "String"),
            @ApiImplicitParam(name = "commentMsg", value = "评论内容", required = true, dataType = "String"),
            @ApiImplicitParam(name = "userId", value = "评论用户Id", required = true, dataType = "String")
    })
    @Transactional
    public ResponseBean addUserNoteComment(@RequestParam("noteId") String noteId, @RequestParam("commentMsg") String commentMsg, @RequestParam("userId") String userId) {

        /** 允许该域发起跨域请求 */
        response.setHeader("Access-Control-Allow-Origin", "*");
        /**  允许的外域请求方式 */
        response.setHeader("Access-Control-Allow-Methods", "POST, GET");
        Integer num = userActivityService.getNoteCommentNum(String.valueOf(noteId)) == null ? 0 : userActivityService.getNoteCommentNum(String.valueOf(1)) + 1;

        return new ResponseBean(ResponseBean.SUCCESS, "添加评论成功!", userActivityService.addUserNoteComment(noteId, userId, commentMsg, String.valueOf(num)));
    }

    @GetMapping("addNoteCommentReply")
    @ApiOperation("添加笔记评论回复")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "commentId", value = "评论Id", required = true, dataType = "String"),
            @ApiImplicitParam(name = "replyMsg", value = "回复内容", required = true, dataType = "String"),
            @ApiImplicitParam(name = "replyUserId", value = "回复用户Id", required = true, dataType = "String")
    })
    public ResponseBean addNoteCommentReply(@RequestParam("commentId") String commentId, @RequestParam("replyMsg") String replyMsg, @RequestParam("replyUserId") String replyUserId) {

        /** 允许该域发起跨域请求 */
        response.setHeader("Access-Control-Allow-Origin", "*");
        /**  允许的外域请求方式 */
        response.setHeader("Access-Control-Allow-Methods", "POST, GET");
        return new ResponseBean(ResponseBean.SUCCESS, "回复评论成功!", userActivityService.addNoteCommentReply(replyUserId, commentId, replyMsg));
    }

    @GetMapping("addCommentReply")
    @ApiOperation("添加活动评论回复")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "commentId", value = "评论Id", required = true, dataType = "String"),
            @ApiImplicitParam(name = "replyMsg", value = "回复内容", required = true, dataType = "String"),
            @ApiImplicitParam(name = "replyUserId", value = "回复用户Id", required = true, dataType = "String")
    })
    public ResponseBean addCommentReply(CommentReplyBo commentReplyBo) {

        /** 允许该域发起跨域请求 */
        response.setHeader("Access-Control-Allow-Origin", "*");
        /**  允许的外域请求方式 */
        response.setHeader("Access-Control-Allow-Methods", "POST, GET");
        return new ResponseBean(ResponseBean.SUCCESS, "回复评论成功!", userActivityService.addCommentReply(commentReplyBo));
    }

    @GetMapping("addNoteCommentLike")
    @ApiOperation("笔记评论点赞")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "commentId", value = "评论Id", required = true, dataType = "String"),
            @ApiImplicitParam(name = "userId", value = "当前用户Id", required = true, dataType = "String")
    })
    public ResponseBean addNoteCommentLike(@RequestParam("commentId") String commentId, @RequestParam("userId") String userId) {

        /** 允许该域发起跨域请求 */
        response.setHeader("Access-Control-Allow-Origin", "*");
        /**  允许的外域请求方式 */
        response.setHeader("Access-Control-Allow-Methods", "POST, GET");
        List<Map<String, String>> list = userActivityService.findNoteCommentLike(commentId, userId);
        Integer likeNum = null;
        if (!list.isEmpty()) {
            String str = list.get(0).toString();
            String[] strings = str.split("like_id=");
            String likeId = strings[1].split("}")[0];
            System.err.println(likeId);
            userActivityService.delNoteCommentLik(likeId);
            likeNum = userActivityService.getNoteCommentLikNum(commentId);
            userActivityService.updateNoteCommentLikeNum(String.valueOf(likeNum), commentId);
            return new ResponseBean(ResponseBean.SUCCESS, "取消点赞!", new LikeNumVo(likeNum, 0));
        }
        userActivityService.addNoteCommentLik(commentId, userId);
        likeNum = userActivityService.getNoteCommentLikNum(commentId);
        userActivityService.updateNoteCommentLikeNum(String.valueOf(likeNum), commentId);
        return new ResponseBean(ResponseBean.SUCCESS, "点赞成功!", new LikeNumVo(likeNum, 1));
    }


    @GetMapping("addCommentLike")
    @ApiOperation("活动评论点赞")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "commentId", value = "评论Id", required = true, dataType = "String"),
            @ApiImplicitParam(name = "userId", value = "当前用户Id", required = true, dataType = "String")
    })
    public ResponseBean addCommentLike(@RequestParam("commentId") String commentId, @RequestParam("userId") String userId) {

        /** 允许该域发起跨域请求 */
        response.setHeader("Access-Control-Allow-Origin", "*");
        /**  允许的外域请求方式 */
        response.setHeader("Access-Control-Allow-Methods", "POST, GET");
        CommentLike commentLike = userActivityService.findCommentLik(commentId, userId);
        Integer likeNum = null;
        if (commentLike != null) {
            userActivityService.delCommentLik(commentLike.getLikeId() + "");
            likeNum = userActivityService.getCommentLikNum(commentId);
            userActivityService.saveOrUpdateLikeNum(String.valueOf(likeNum), commentId);
            return new ResponseBean(ResponseBean.SUCCESS, "取消点赞!", new LikeNumVo(likeNum, 0));
        }
        userActivityService.addCommentLik(commentId, userId);
        likeNum = userActivityService.getCommentLikNum(commentId);
        userActivityService.saveOrUpdateLikeNum(String.valueOf(likeNum), commentId);
        return new ResponseBean(ResponseBean.SUCCESS, "点赞成功!", new LikeNumVo(likeNum, 1));
    }

    @GetMapping("getNoteCommentAndReply")
    @ApiOperation("获取笔记的评论和回复")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "noteId", value = "笔记Id", required = true, dataType = "String"),
            @ApiImplicitParam(name = "userId", value = "当前用户Id", required = true, dataType = "String")
    })
    public ResponseBean getNoteCommentAndReply(@RequestParam("noteId") String noteId, @RequestParam("userId") String userId) {

        /** 允许该域发起跨域请求 */
        response.setHeader("Access-Control-Allow-Origin", "*");
        /**  允许的外域请求方式 */
        response.setHeader("Access-Control-Allow-Methods", "POST, GET");
        return new ResponseBean(ResponseBean.SUCCESS, "", userActivityService.getNoteCommentAndReply(noteId, userId));
    }

    @GetMapping("getCommentAndReply")
    @ApiOperation("获取活动的评论和回复")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "activityId", value = "活动Id", required = true, dataType = "String"),
            @ApiImplicitParam(name = "userId", value = "当前用户Id", required = true, dataType = "String")
    })
    public ResponseBean getCommentAndReply(@RequestParam("activityId") String activityId, @RequestParam("userId") String userId) {

        /** 允许该域发起跨域请求 */
        response.setHeader("Access-Control-Allow-Origin", "*");
        /**  允许的外域请求方式 */
        response.setHeader("Access-Control-Allow-Methods", "POST, GET");
        return new ResponseBean(ResponseBean.SUCCESS, "", userActivityService.getCommentAndReply(activityId, userId));
    }

    @GetMapping("addNoteLike")
    @ApiOperation("动态点赞")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "笔记Id", required = true, dataType = "String"),
            @ApiImplicitParam(name = "user_id", value = "当前用户Id", required = true, dataType = "String")
    })
    public ResponseBean addNoteLike(@RequestParam("id") String noteId, @RequestParam("user_id") String userId) {

        /** 允许该域发起跨域请求 */
        response.setHeader("Access-Control-Allow-Origin", "*");
        /**  允许的外域请求方式 */
        response.setHeader("Access-Control-Allow-Methods", "POST, GET");
        Integer likeNum = null;
        List<Map<String, String>> map = userActivityService.getUserNoteLikeMap(noteId, userId);
        if (map != null && !map.isEmpty()) {
            /** 取消点赞 */
            userActivityService.delUserNoteLikeMap(noteId, userId);
            likeNum = userActivityMapper.findUserNoteLikeNum(noteId);
            userActivityMapper.updateNoteLikeNum(noteId, String.valueOf(likeNum));
            return new ResponseBean(ResponseBean.SUCCESS, "取消点赞!", new LikeNumVo(likeNum, 0));
        } else {
            userActivityService.addUserNoteLikeMap(noteId, userId);
            likeNum = userActivityMapper.findUserNoteLikeNum(noteId);
            userActivityMapper.updateNoteLikeNum(noteId, String.valueOf(likeNum));
            return new ResponseBean(ResponseBean.SUCCESS, "点赞成功!", new LikeNumVo(likeNum, 1));
        }
    }

    @GetMapping("addNoteCollect")
    @ApiOperation("动态收藏")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "动态Id", required = true, dataType = "String"),
            @ApiImplicitParam(name = "user_id", value = "当前用户Id", required = true, dataType = "String")
    })
    @Transactional
    public ResponseBean addNoteCollect(@RequestParam("id") String noteId, @RequestParam("user_id") String userId) {

        /** 允许该域发起跨域请求 */
        response.setHeader("Access-Control-Allow-Origin", "*");
        /**  允许的外域请求方式 */
        response.setHeader("Access-Control-Allow-Methods", "POST, GET");
        List<Map<String, String>> map = userActivityService.getUserNoteCollectMap(noteId, userId);
        Integer collectNum = null;
        if (map != null && !map.isEmpty()) {
            /** 取消收藏 */
            userActivityService.delUserNoteCollectMap(noteId, userId);
            collectNum = userActivityMapper.findUserNoteCollectNum(noteId);
            userActivityMapper.updateNoteCollectNum(noteId, String.valueOf(collectNum));
            return new ResponseBean(ResponseBean.SUCCESS, "取消收藏!", new CollectNumVo(collectNum, 0));
        } else {
            userActivityService.addUserNoteCollectMap(noteId, userId);
            collectNum = userActivityMapper.findUserNoteCollectNum(noteId);
            userActivityMapper.updateNoteCollectNum(noteId, String.valueOf(collectNum));
            return new ResponseBean(ResponseBean.SUCCESS, "收藏成功!", new CollectNumVo(collectNum, 1));
        }
    }


    @GetMapping("addActivityLike")
    @ApiOperation("活动点赞")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "activity_id", value = "活动Id", required = true, dataType = "String"),
            @ApiImplicitParam(name = "user_id", value = "当前用户Id", required = true, dataType = "String")
    })
    public ResponseBean addActivityLike(@RequestParam("activity_id") String activityId, @RequestParam("user_id") String userId) {

        /** 允许该域发起跨域请求 */
        response.setHeader("Access-Control-Allow-Origin", "*");
        /**  允许的外域请求方式 */
        response.setHeader("Access-Control-Allow-Methods", "POST, GET");
        Integer likeNum = null;
        List<Map<String, String>> map = userActivityService.getUserActivityLikeMap(activityId, userId);
        if (map != null && !map.isEmpty()) {
            /** 取消点赞 */
            userActivityService.delUserActivityLikeMap(activityId, userId);
            likeNum = userActivityMapper.findUserActivityLikeNum(activityId);
            userActivityMapper.updateLikeNum(activityId, likeNum + "");

            return new ResponseBean(ResponseBean.SUCCESS, "取消点赞!", new LikeNumVo(likeNum, 0));
        } else {
            userActivityService.addUserActivityLikeMap(activityId, userId);
            likeNum = userActivityMapper.findUserActivityLikeNum(activityId);
            userActivityMapper.updateLikeNum(activityId, likeNum + "");
            return new ResponseBean(ResponseBean.SUCCESS, "点赞成功!", new LikeNumVo(likeNum, 1));
        }
    }

    @GetMapping("addActivityCollect")
    @ApiOperation("活动收藏")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "activityId", value = "活动Id", required = true, dataType = "String"),
            @ApiImplicitParam(name = "userId", value = "当前用户Id", required = true, dataType = "String")
    })
    public ResponseBean addActivityCollect(@RequestParam("activityId") String activityId, @RequestParam("userId") String userId) {

        /** 允许该域发起跨域请求 */
        response.setHeader("Access-Control-Allow-Origin", "*");
        /**  允许的外域请求方式 */
        response.setHeader("Access-Control-Allow-Methods", "POST, GET");
        List<Map<String, String>> map = userActivityService.getUserActivityCollectMap(activityId, userId);
        Integer collectNum = null;
        if (map != null && !map.isEmpty()) {
            /** 取消收藏 */
            userActivityService.delUserActivityCollectMap(activityId, userId);
            collectNum = userActivityMapper.findUserActivityCollectNum(activityId);
            userActivityMapper.updateCollectNum(activityId, String.valueOf(collectNum));
            return new ResponseBean(ResponseBean.SUCCESS, "取消收藏!", new CollectNumVo(collectNum, 0));
        } else {
            userActivityService.addUserActivityCollectMap(activityId, userId);
            collectNum = userActivityMapper.findUserActivityCollectNum(activityId);
            userActivityMapper.updateCollectNum(activityId, String.valueOf(collectNum));
            return new ResponseBean(ResponseBean.SUCCESS, "收藏成功!", new CollectNumVo(collectNum, 1));
        }
    }

    @GetMapping("addActivityPhotoLike")
    @ApiOperation("图片点赞")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "wallId", value = "图片Id", required = true, dataType = "String"),
            @ApiImplicitParam(name = "userId", value = "当前用户Id", required = true, dataType = "String")
    })
    public ResponseBean addActivityPhotoLike11(@RequestParam("wallId") String wallId, @RequestParam("userId") String userId) {

        /** 允许该域发起跨域请求 */
        response.setHeader("Access-Control-Allow-Origin", "*");
        /**  允许的外域请求方式 */
        response.setHeader("Access-Control-Allow-Methods", "POST, GET");
        List<Map<String, String>> map = userActivityService.getPhotoWallLike(wallId, userId);
        Integer likeNum = null;
        if (map != null && !map.isEmpty()) {
            /** 取消点赞 */
            userActivityService.delPotoWallLike(wallId, userId);
            likeNum = userActivityMapper.getPhotoWallLikeNum(wallId);
            userActivityMapper.updatePhotoWallLikeNum(likeNum, wallId);
            return new ResponseBean(ResponseBean.SUCCESS, "取消点赞", new LikeNumVo(likeNum, 0));
        } else {
            userActivityService.addPhotoWallLike(wallId, userId);
            likeNum = userActivityMapper.getPhotoWallLikeNum(wallId);
            userActivityMapper.updatePhotoWallLikeNum(userActivityMapper.getPhotoWallLikeNum(wallId), wallId);
            return new ResponseBean(ResponseBean.SUCCESS, "点赞成功", new LikeNumVo(likeNum, 1));

        }
    }

    /**
     * 获取活动
     *
     * @param
     * @return
     */
    @PostMapping("/geUserActivityByClassifyId")
    @ApiOperation("根据活动类型获取活动")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "timeSelection", value = "weekend(周末)  a_week(一周) a_month(一个月)", required = false, dataType = "String"),
            @ApiImplicitParam(name = "lat2", value = "用户当前位置的纬度", required = false, dataType = "String"),
            @ApiImplicitParam(name = "lng2", value = "用户当前位置的经度", required = false, dataType = "String"),
            @ApiImplicitParam(name = "type", value = "类型 0按时间排序 1 按距离排序", required = false, dataType = "String"),
            @ApiImplicitParam(name = "province", value = "省", required = false, dataType = "String"),
            @ApiImplicitParam(name = "city", value = "市", required = false, dataType = "String"),
            @ApiImplicitParam(name = "area", value = "区", required = false, dataType = "String"),
            @ApiImplicitParam(name = "userId", value = "当前用户的Id", required = true, dataType = "String"),
            @ApiImplicitParam(name = "classifyId", value = "活动分类Id", required = true, dataType = "String")
    })
    public ResponseBean geUserActivityByClassifyId(FindUserActivityVo findUserActivityVo, @RequestParam("pageNum") String pageNum, @RequestParam("pageSize") String pageSize) {

        /** 允许该域发起跨域请求 */
        response.setHeader("Access-Control-Allow-Origin", "*");
        /**  允许的外域请求方式 */
        response.setHeader("Access-Control-Allow-Methods", "POST, GET");
        Map<String, String> map = JavaBeanUtil.convertBeanToMap(findUserActivityVo);
        List<UserActivityVo> list = userActivityService.findUserActivityVo(map);
        return new ResponseBean(ResponseBean.SUCCESS, "", SubListUtils.subList(Integer.parseInt(pageNum), Integer.parseInt(pageSize), list));
    }
    @GetMapping("getActivityDetail")
    @ApiOperation("获取活动详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "activity_id", value = "活动Id", required = true, dataType = "String"),
            @ApiImplicitParam(name = "user_id", value = "当前用户Id", required = true, dataType = "String")})
    public ResponseBean getActivityDetail(@RequestParam("activity_id") String activityId, @RequestParam("user_id") String userId) {

        /** 允许该域发起跨域请求 */
        response.setHeader("Access-Control-Allow-Origin", "*");
        /**  允许的外域请求方式 */
        response.setHeader("Access-Control-Allow-Methods", "POST, GET");
        Map<String,Object> map = new HashMap<>();
        map.put("detatil",userActivityService.getActivityDetail(activityId, userId));
        map.put("like",userActivityMapper.getSomeLike());
        map.put("recommend",userActivityMapper.getSomeRecommend());
        map.put("comment",userActivityService.getCommentAndReply(activityId, userId));
        return new ResponseBean(ResponseBean.SUCCESS, "", map);
    }
    @GetMapping("getNoteDetail")
    @ApiOperation("获取活动详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "note_id", value = "活动Id", required = true, dataType = "String"),
            @ApiImplicitParam(name = "user_id", value = "当前用户Id", required = true, dataType = "String")})
    public ResponseBean getNoteDetail(@RequestParam("note_id") String noteId, @RequestParam("user_id") String userId) {

        /** 允许该域发起跨域请求 */
        response.setHeader("Access-Control-Allow-Origin", "*");
        /**  允许的外域请求方式 */
        response.setHeader("Access-Control-Allow-Methods", "POST, GET");
        Map<String,Object> map = new HashMap<>();
        map.put("detatil",userActivityService.getNoteDetail(noteId, userId));
        map.put("like",userActivityMapper.getSomeLike());
        return new ResponseBean(ResponseBean.SUCCESS, "", map);
    }

}